# -*- coding: utf-8 -*-

# Define here the models for your spider middleware
#
# See documentation in:
# https://doc.scrapy.org/en/latest/topics/spider-middleware.html
import random
from .settings import PROXYS
from .settings import USER_AGENTS


class RandomProxy(object):

    def process_request(self, request, spider):
        proxy = random.choice(PROXYS)
        request.meta['proxy'] = proxy


class RandomUserAgent(object):

    def process_request(self, request, spider):
        user_agent = random.choice(USER_AGENTS)
        request.headers.setdefault("User-Agent", user_agent)